package leetcode.code543.DiameterofBinaryTree;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;
import leetcode.helper.tree.TreeArray;
import leetcode.helper.tree.TreeNode;

public abstract class DiameterofBinaryTree implements IDebug {

	abstract public int diameterOfBinaryTree(TreeNode root);

	public void debug(String string, int expect) {
//		Input: root = [1,2,3,4,5]
//		Output: 3

		TreeNode root = TreeArray.array2tree(HelpDebug.str2array4(string));
		int result = this.diameterOfBinaryTree(root);
		System.out.println((result == expect) + "  >>> " + result);
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub
		String string = "[1,2,3,4,5]";
		int expect = 3;
		this.debug(string, expect);
	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub
		String string = "[1,2]";
		int expect = 1;
		this.debug(string, expect);
	}

	@Override
	public void debug3() {

		// TODO Auto-generated method stub
		Integer[] string = { 2, 5, null, 3, null, 1, 4 };
		int expect = 3;
		TreeNode root = TreeArray.array2tree(string);
		int result = this.diameterOfBinaryTree(root);
		System.out.println((result == expect) + "  >>> " + result);

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

}
